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

Using this.type, an expression can compile if broken into assignments and not if given inline. #2435

Closed
scabug opened this Issue Oct 3, 2009 · 5 comments

Comments

Projects
None yet
2 participants
@scabug
Copy link

scabug commented Oct 3, 2009

This is the narrowest test case I could arrange. If necessary, I can provide a larger code sample where the bug actually harms clarity:

object Bug {
  abstract class FChain {
    type T

    def chain(constant:String) =
      new FConstant[this.type](constant, this) //removing [this.type], everything compiles
  }

  case class FConstant[E <: FChain](constant:String, tail:E) extends FChain {
    type T = tail.T
  }
  
  object FNil extends FChain {
    type T = Unit
  }

}

import Bug._
println("Compiles:")
val a1 = FNil.chain("a").chain("a")
val a2 = a1.chain("a")

println("\nDoesn't compile:")
val a = FNil.chain("a").chain("a").chain("a")

This code is the same as the attached file.

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Oct 3, 2009

Imported From: https://issues.scala-lang.org/browse/SI-2435?orig=1
Reporter: Rafael de F. Ferreira (rafaeldff)
Attachments:

  • Bug.scala (created on Oct 3, 2009 4:59:42 PM UTC, 513 bytes)
@scabug

This comment has been minimized.

Copy link
Author

scabug commented Oct 3, 2009

Rafael de F. Ferreira (rafaeldff) said:
Same code as provided in the description, can be run as a script or loaded in the REPL

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Oct 20, 2009

@adriaanm said:
ok, and the error message is:

 found   : Bug.FConstant[_2.type(in value a)] where type _2.type(in value a) <: Bug.FConstant[_1.type] with Singleton
 required: Bug.FConstant[_2.type(in value a)] forSome { type _2.type(in value a) <: Bug.FConstant[_1.type] with Singleton; val _1: Bug.FConstant[Bug.FNil.type] }
  val a = FNil.chain("a").chain("a").chain("a")
      ^

seems like some existential type got stripped or something.. I'll take a look ASAP.

@scabug

This comment has been minimized.

Copy link
Author

scabug commented May 11, 2012

@retronym said:
Test case in:

scala/scala#528

@scabug scabug closed this May 11, 2012

@scabug

This comment has been minimized.

Copy link
Author

scabug commented May 11, 2012

@scabug scabug added this to the 2.10.0-M3 milestone Apr 7, 2017

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