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

Type mismatch: apparent regression in LUBs #8224

Closed
scabug opened this issue Feb 1, 2014 · 10 comments
Closed

Type mismatch: apparent regression in LUBs #8224

scabug opened this issue Feb 1, 2014 · 10 comments

Comments

@scabug
Copy link

scabug commented Feb 1, 2014

The following did compile with 2.10 but now "type mismatch" is reported:

import language.higherKinds

trait EL[+N] extends Equals with Serializable
type  ELI[N] = EL[N]

trait P  [N, +E[X<:N] <: EL[X]]
trait PIn[N, +E[X<:N] <: EL[X]] extends P[N,E]

trait EI [N, +E[X<:N] <: EL[X]] extends PIn[N,E]
case class NI[N](value: N) extends PIn[N, Nothing]

def seqToP[N, E[X <: N] <: ELI[X]](s: Seq[N]): Seq[PIn[N, E]] = s map {
  _ match {
    case e: EL[N] with EI[N,E] => e
    case n => NI(n)
  }
}

For me it would suffice to adequately alter the method definition without any change in signatures.

@scabug
Copy link
Author

scabug commented Feb 1, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8224?orig=1
Reporter: Sonnenschein (sonnenschein)
Affected Versions: 2.11.0-M8
See #2251, #7694

@scabug
Copy link
Author

scabug commented Feb 1, 2014

Sonnenschein (sonnenschein) said:
(Sorry, the description editor saved new lines in the match expr at the wrong position.)

@scabug
Copy link
Author

scabug commented Feb 1, 2014

@retronym said:
Regressed in scala/scala@db46c71

@scabug
Copy link
Author

scabug commented Feb 1, 2014

@retronym said:
Marking as a blocker so that we at least better characterise this before 2.11.0

@scabug
Copy link
Author

scabug commented Feb 1, 2014

@retronym said (edited on Feb 1, 2014 4:19:21 PM UTC):
Minimized:

import language.higherKinds
 
trait P  [N1, +E1[X <: N1]]
trait PIn[N2, +E2[X <: N2]] extends P[Int,Any]

trait EI extends PIn[Int, Nothing]
trait NI extends PIn[Int, Nothing]

object Test { 
  val lub = if (true) ??? : EI else ??? : NI
  val pin: PIn[Int,Nothing] = lub
}

@scabug
Copy link
Author

scabug commented Feb 1, 2014

@retronym said:

scalac-hash  db46c71e8830639bc79e6363332a06642fd3d8c -Ylog:typer sandbox/test.scala
[log typer] [+symbol] type X (flags: <deferred> <param>)
[log typer] [+symbol] type X (flags: <deferred> <param>)
[log typer] Breaking recursion in lublist, substituting weaker type.
  Was: PIn[Any,Nothing]
  Now: P[Int,Any]
[log typer] Breaking recursion in lublist, substituting weaker type.
  Was: PIn[Any,Nothing]
  Now: P[Int,Any]
[log typer] computing param aliases for object Test:()Test.type:{
  Test.super.<init>();
  ()
}
sandbox/test.scala:11: error: type mismatch;
 found   : P[Int,Any]
 required: PIn[Int,Nothing]
  val pin: PIn[Int,Nothing] = lub
                              ^
one error found

@scabug
Copy link
Author

scabug commented Feb 1, 2014

@retronym said:
Not our greatest day at the code review factory: scala/scala#1122

@scabug
Copy link
Author

scabug commented Feb 1, 2014

@retronym said (edited on Feb 1, 2014 5:20:07 PM UTC):
Here's my analysis and a partial fix:

https://github.com/retronym/scala/tree/ticket/8224

/cc Adriaan for post-factum review of the original change. I don't think its too hard to refine Paul's approach a bit more, but if you decide to go another way I can save the effort.

@scabug
Copy link
Author

scabug commented Feb 1, 2014

@retronym said:
See also: #7694, @uncheckedBounds

@scabug
Copy link
Author

scabug commented Feb 19, 2014

@adriaanm said:
scala/scala#3557

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

2 participants