Skip to content

crashy interplay between value class, existentials, inference #7818

Description

@scabug
class Observable1[+T](val asJava: JObservable[_ <: T]) extends AnyVal {
  private def foo[X](a: JObservable[X]): JObservable[X] = ???
  def synchronize: Observable1[T] = new Observable1(foo(asJava))
}

class JObservable[T]
scalac-hash v2.11.0-M4 sandbox/value-class-existential.scala
[info] v2.11.0-M4 => /Users/jason/usr/scala-v2.11.0-M4-0-g8b41240
error: scala.reflect.internal.Types$TypeError: type mismatch;
 found   : Observable1[_$1] where type _$1 <: T
 required: Observable1[T]
	at scala.tools.nsc.typechecker.Contexts$Context.issue(Contexts.scala:549)
	at scala.tools.nsc.typechecker.ContextErrors$ErrorUtils$.issueTypeError(ContextErrors.scala:97)
	at scala.tools.nsc.typechecker.ContextErrors$ErrorUtils$.issueNormalTypeError(ContextErrors.scala:86)
	at scala.tools.nsc.typechecker.ContextErrors$TyperContextErrors$TyperErrorGen$.AdaptTypeError(ContextErrors.scala:184)
	at scala.tools.nsc.typechecker.Typers$Typer.adaptMismatchedSkolems$1(Typers.scala:1126)
	at scala.tools.nsc.typechecker.Typers$Typer.fallbackAfterVanillaAdapt$1(Typers.scala:1195)
	at scala.tools.nsc.typechecker.Typers$Typer.vanillaAdapt$1(Typers.scala:1232)
	at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:1275)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5370)
	at scala.tools.nsc.typechecker.Typers$Typer.transformedOrTyped(Typers.scala:5554)
	at scala.tools.nsc.typechecker.Typers$Typer.typedDefDef(Typers.scala:2307)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5281)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5352)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5411)
	at scala.tools.nsc.typechecker.Typers$Typer.typedPos(Typers.scala:5418)
	at scala.tools.nsc.transform.ExtensionMethods$Extender$$anonfun$transformStats$1$$anonfun$10$$anonfun$apply$9.apply(ExtensionMethods.scala:260)
	at scala.tools.nsc.transform.ExtensionMethods$Extender$$a

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions