scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

Weird scala.reflect.internal.Types$TypeError: type mismatch #10153

Open scabug opened 7 years ago

scabug commented 7 years ago

The following code

package test

import java.net.URI
import org.springframework.http.HttpMethod
import org.springframework.http.client.ClientHttpRequestFactory
import org.springframework.web.client._

class RetryingRestTemplate(f: ClientHttpRequestFactory)
    extends RestTemplate(f) {

  override protected def doExecute[T](
      url: URI,
      method: HttpMethod,
      requestCallback: RequestCallback,
      responseExtractor: ResponseExtractor[T]): T = {
    defer {
      super.doExecute(url, method, requestCallback, responseExtractor)
    }
  }

  private def defer[T](thunk: => T): T = thunk
}

Crashes the compiler with

scala.reflect.internal.Types$TypeError: type mismatch;
 found   : RetryingRestTemplate.super.type (with underlying type org.springframework.web.client.RestTemplate)
 required: test.RetryingRestTemplate

Reproduced with both 2.11.8 and 2.12.1.

Attached is an SBT project exhibiting the problem, minified as far as I am able.

scabug commented 7 years ago

Imported From: https://issues.scala-lang.org/browse/SI-10153?orig=1 Reporter: Espen Wiborg (espenhw) Affected Versions: 2.11.8, 2.12.1 Attachments: