Skip to content

Narrowing of types is too shallow #7585

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

Closed
scabug opened this issue Jun 18, 2013 · 8 comments
Closed

Narrowing of types is too shallow #7585

scabug opened this issue Jun 18, 2013 · 8 comments
Assignees

Comments

@scabug
Copy link

scabug commented Jun 18, 2013

I run into this problem when refactoring the cake:

trait Outer { outer =>
  val other: Other
  // type checks
  val f = (Outer.this.other: outer.other.type)
  // fails to type check:
  // type mismatch;
  // found : Outer.this.other.type (with underlying type Other)
  // required: Outer{val other: Outer.this.other.type}
  val alias: Outer { val other: outer.other.type } = Outer.this 
}

abstract class Other

This looks like should be trivially true but it fails to type check. According to Adriaan it fails because narrowing of types is to shallow and is not being applied to members.

This will be probably closed as Won't Fix but I filed it just for record.

@scabug
Copy link
Author

scabug commented Jun 18, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7585?orig=1
Reporter: @gkossakowski
Affected Versions: 2.11.0-M3

@scabug
Copy link
Author

scabug commented Jun 18, 2013

@gkossakowski said:
Added Jason to watcher as I'm sure he might enjoy seeing this fun problem.

@scabug
Copy link
Author

scabug commented Aug 1, 2013

@paulp said:
It can lose several of the players:

trait Outer {
  val x: Object
  def alias: Outer { val x: Outer.this.x.type } = this
}

@scabug
Copy link
Author

scabug commented Aug 1, 2013

@paulp said:
Also, it's a duplicate of #4663.

@scabug
Copy link
Author

scabug commented Aug 1, 2013

@paulp said:
See also #6767 and the other tickets linked there. I'm not sure there's any benefit in opening more variations on "the singleton type is not correctly propagated."

@scabug
Copy link
Author

scabug commented Aug 1, 2013

@gkossakowski said:
No, there's no benefit apart from documenting that people run into this problem on various occasions.

I was very surprised to discover that "this" doesn't to the that trivial refinement especially when the type ascription works.

@scabug scabug closed this as completed Aug 1, 2013
@scabug
Copy link
Author

scabug commented Aug 1, 2013

@paulp said:
I remember this feeling, surprise. Gave life a certain zest.

@scabug
Copy link
Author

scabug commented Aug 1, 2013

@paulp said:
Also, I'm sure you can head off a few dozen duplicates-to-be by reading the issues I have reported which are still open. There are 142 of them. I promise you will encounter enough of these issues in practice to justify the initial investment. I put an awful lot of increasingly pointless-seeming work into them. Here they are.

https://issues.scala-lang.org/secure/IssueNavigator.jspa?mode=hide&requestId=12210

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