Fix compile in Scala 2.10.1+ #1509

Merged
merged 1 commit into from Jan 16, 2014

Conversation

Projects
None yet
4 participants
@pbrant
Member

pbrant commented Dec 20, 2013

Scala 2.10.1 includes a type checking bug fix that causes compilation to
fail. Add casts to work around this (effectively restoring the previous
behavior).

Fix compile in Scala 2.10.1+
Scala 2.10.1 includes a type checking bug fix that causes compilation to
fail.  Add casts to work around this (effectively restoring the previous
behavior).
@@ -360,7 +360,7 @@ trait AbstractScreen extends Factory {
case AVal(v: (T => List[FieldError])) => v
},
stuff.toList.collect {
- case AFilter(v) => v
+ case AFilter(v) => v.asInstanceOf[T => T]

This comment has been minimized.

@farmdawgnation

farmdawgnation Dec 20, 2013

Member

So, do we want to add an if isInstanceOf[T => T] to these case statements as well? As such, this will throw an exception if it can't fit into the type. May not be a horrible idea to log a warning or something as well...

@farmdawgnation

farmdawgnation Dec 20, 2013

Member

So, do we want to add an if isInstanceOf[T => T] to these case statements as well? As such, this will throw an exception if it can't fit into the type. May not be a horrible idea to log a warning or something as well...

This comment has been minimized.

@Shadowfiend

Shadowfiend Dec 20, 2013

Member

I'm down for the isInstanceOf check, though it's worth mentioning that AFilter should already be providing a compiler check for the type. I think the only real concern here is reflection or something similarly weird that would ignore the compiler and run in a type-erased context could theoretically send in something other than what's expected.

@Shadowfiend

Shadowfiend Dec 20, 2013

Member

I'm down for the isInstanceOf check, though it's worth mentioning that AFilter should already be providing a compiler check for the type. I think the only real concern here is reflection or something similarly weird that would ignore the compiler and run in a type-erased context could theoretically send in something other than what's expected.

This comment has been minimized.

@pbrant

pbrant Dec 20, 2013

Member

The compiler verification on AFilter construction isn't sufficient. 2.10.0
and earlier didn't complain and happily assumed T => T. 2.10.1+ does
complain. See https://issues.scala-lang.org/browse/SI-5189 . The cast is
basically restoring the pre-2.10.1 behavior (which is wrong, but mostly
good enough).

On Fri, Dec 20, 2013 at 3:17 PM, Antonio Salazar Cardozo <
notifications@github.com> wrote:

In web/webkit/src/main/scala/net/liftweb/http/LiftScreen.scala:

@@ -360,7 +360,7 @@ trait AbstractScreen extends Factory {
case AVal(v: (T => List[FieldError])) => v
},
stuff.toList.collect {

  •    case AFilter(v) => v
    
  •    case AFilter(v) => v.asInstanceOf[T => T]
    

I'm down for the isInstanceOf check, though it's worth mentioning that
AFilter should already be providing a compiler check for the type. I
think the only real concern here is reflection or something similarly weird
that would ignore the compiler and run in a type-erased context could
theoretically send in something other than what's expected.


Reply to this email directly or view it on GitHubhttps://github.com/lift/framework/pull/1509/files#r8500039
.

@pbrant

pbrant Dec 20, 2013

Member

The compiler verification on AFilter construction isn't sufficient. 2.10.0
and earlier didn't complain and happily assumed T => T. 2.10.1+ does
complain. See https://issues.scala-lang.org/browse/SI-5189 . The cast is
basically restoring the pre-2.10.1 behavior (which is wrong, but mostly
good enough).

On Fri, Dec 20, 2013 at 3:17 PM, Antonio Salazar Cardozo <
notifications@github.com> wrote:

In web/webkit/src/main/scala/net/liftweb/http/LiftScreen.scala:

@@ -360,7 +360,7 @@ trait AbstractScreen extends Factory {
case AVal(v: (T => List[FieldError])) => v
},
stuff.toList.collect {

  •    case AFilter(v) => v
    
  •    case AFilter(v) => v.asInstanceOf[T => T]
    

I'm down for the isInstanceOf check, though it's worth mentioning that
AFilter should already be providing a compiler check for the type. I
think the only real concern here is reflection or something similarly weird
that would ignore the compiler and run in a type-erased context could
theoretically send in something other than what's expected.


Reply to this email directly or view it on GitHubhttps://github.com/lift/framework/pull/1509/files#r8500039
.

This comment has been minimized.

@Shadowfiend

Shadowfiend Dec 20, 2013

Member

I realize that. I'm not saying asInstanceOf isn't necessary, I'm saying isInstanceOf might be too much, depending on whether we view this as dealing with something we know but the compiler doesn't, or whether we view this as dealing with the potential for someone to get around the compiler to give us bad data :)

@Shadowfiend

Shadowfiend Dec 20, 2013

Member

I realize that. I'm not saying asInstanceOf isn't necessary, I'm saying isInstanceOf might be too much, depending on whether we view this as dealing with something we know but the compiler doesn't, or whether we view this as dealing with the potential for someone to get around the compiler to give us bad data :)

This comment has been minimized.

@fmpwizard

fmpwizard Dec 22, 2013

Member

I'll let you guys decide on this one, once you all agree, just let me know and I'll press the green merge button (or any of you could do it too :) )

@fmpwizard

fmpwizard Dec 22, 2013

Member

I'll let you guys decide on this one, once you all agree, just let me know and I'll press the green merge button (or any of you could do it too :) )

@Shadowfiend

This comment has been minimized.

Show comment
Hide comment
@Shadowfiend

Shadowfiend Jan 16, 2014

Member

Is this ready to go, @pbrant ? I don't know if you decided either way on the isInstanceOf check above.

Member

Shadowfiend commented Jan 16, 2014

Is this ready to go, @pbrant ? I don't know if you decided either way on the isInstanceOf check above.

@pbrant

This comment has been minimized.

Show comment
Hide comment
@pbrant

pbrant Jan 16, 2014

Member

I don't have any better ideas (i.e. I think it's good to go).

On Thu, Jan 16, 2014 at 3:38 PM, Antonio Salazar Cardozo <
notifications@github.com> wrote:

Is this ready to go, @pbrant https://github.com/pbrant ? I don't know
if you decided either way on the isInstanceOf check above.


Reply to this email directly or view it on GitHubhttps://github.com/lift/framework/pull/1509#issuecomment-32473676
.

Member

pbrant commented Jan 16, 2014

I don't have any better ideas (i.e. I think it's good to go).

On Thu, Jan 16, 2014 at 3:38 PM, Antonio Salazar Cardozo <
notifications@github.com> wrote:

Is this ready to go, @pbrant https://github.com/pbrant ? I don't know
if you decided either way on the isInstanceOf check above.


Reply to this email directly or view it on GitHubhttps://github.com/lift/framework/pull/1509#issuecomment-32473676
.

Shadowfiend added a commit that referenced this pull request Jan 16, 2014

Merge pull request #1509 from lift/pmb_liftscreenfix
Fix compile in Scala 2.10.1+

Scala 2.10.1 included a type checking bug fix that caused compilation to
fail for AFilter pattern matches. Add casts to work around this (effectively
restoring the previous behavior of scalac, but explicitly).

@Shadowfiend Shadowfiend merged commit fd38c7a into master Jan 16, 2014

@Shadowfiend Shadowfiend deleted the pmb_liftscreenfix branch Jan 16, 2014

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