Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typecheck failed if an existential type is inlined #10039

Open
scabug opened this issue Nov 10, 2016 · 1 comment
Open

Typecheck failed if an existential type is inlined #10039

scabug opened this issue Nov 10, 2016 · 1 comment

Comments

@scabug
Copy link

scabug commented Nov 10, 2016

Welcome to Scala 2.12.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_102).
Type in expressions for evaluation. Or try :help.

scala> trait InvariantContainer[Value0] {
     |   type Value = Value0
     | }
defined trait InvariantContainer

scala> type ValueOf[Container <: InvariantContainer[_]] = container.Value forSome { val container: Container }
warning: there was one feature warning; for details, enable `:setting -feature' or `:replay -feature'
defined type alias ValueOf

scala> def intIsValueOfIntContainer(x: Int): ValueOf[InvariantContainer[Int]] = x
intIsValueOfIntContainer: (x: Int)ValueOf[InvariantContainer[Int]]

scala> type OptionValueOf[Container <: InvariantContainer[_]] = Option[ValueOf[Container]]
defined type alias OptionValueOf

scala> def optionIntIsOptionValueOfIntContainer(x: Option[Int]): OptionValueOf[InvariantContainer[Int]] = x
optionIntIsOptionValueOfIntContainer: (x: Option[Int])OptionValueOf[InvariantContainer[Int]]

scala> type InlineOptionValueOf[Container <: InvariantContainer[_]] = Option[container.Value forSome { val container: Container }]
warning: there was one feature warning; for details, enable `:setting -feature' or `:replay -feature'
defined type alias InlineOptionValueOf

scala> def optionIntIsInlineOptionValueOfIntContainer(x: Option[Int]): InlineOptionValueOf[InvariantContainer[Int]] = x
<console>:13: error: type mismatch;
 found   : Option[Int]
 required: InlineOptionValueOf[InvariantContainer[Int]]
    (which expands to)  Option[Int[]]
       def optionIntIsInlineOptionValueOfIntContainer(x: Option[Int]): InlineOptionValueOf[InvariantContainer[Int]] = x
                                                                                                                      ^

optionIntIsInlineOptionValueOfIntContainer should not error because InlineOptionValueOf is simply an inline version of OptionValueOf. I expect InlineOptionValueOf behaves the same as OptionValueOf.

@scabug
Copy link
Author

scabug commented Nov 10, 2016

Imported From: https://issues.scala-lang.org/browse/SI-10039?orig=1
Reporter: @Atry
Affected Versions: 2.12.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant