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 on second compilation #7543

Closed
scabug opened this issue May 31, 2013 · 3 comments
Closed

Type mismatch on second compilation #7543

scabug opened this issue May 31, 2013 · 3 comments
Assignees

Comments

@scabug
Copy link

scabug commented May 31, 2013

Create file:

// core/package.scala
package test

package object core {

  sealed trait Result[T]
  case class Success[T](data: T) extends Result[T]
  case class Failure[T](errorText: String) extends Result[T]

  def f(): Result[Int] = {
    Success[Int](2): Result[Int]
  }
}

Now compile it:

  $ ~/dev/scala-2.10.1/bin/scalac core/package.scala

all is OK. Compile it again:

  $ ~/dev/scala-2.10.1/bin/scalac core/package.scala
  core/package.scala:10: error: type mismatch;
   found   : test.core.Success[Int]
   required: test.core.package.Result[Int]
      Success[Int](2): Result[Int]
                ^
  one error found
@scabug
Copy link
Author

scabug commented May 31, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7543?orig=1
Reporter: Mikhail Trishchenkov (kriomant)
Affected Versions: 2.10.1, 2.10.2-RC1
See #5954

@scabug
Copy link
Author

scabug commented May 31, 2013

@retronym said (edited on May 31, 2013 3:47:16 PM UTC):
Sounds very similar to #5954. Creating classes in package objects is not recommended.

@scabug
Copy link
Author

scabug commented May 31, 2013

@paulp said:
Especially case classes.

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