13 Oct 18:40
illegal match allowed by scalac
From: Eugene Vigdorchik <eugene.vigdorchik <at> gmail.com>
Subject: illegal match allowed by scalac
Newsgroups: gmane.comp.lang.scala
Date: 2008-10-13 16:44:05 GMT
Subject: illegal match allowed by scalac
Newsgroups: gmane.comp.lang.scala
Date: 2008-10-13 16:44:05 GMT
Hi,
the following session fails with MatchError for obvious reasons, but the compiler is happy with this code. Should it signal it? (I'm using 2.7.2-RC2)
scala> class ScType
defined class ScType
scala> var t : Option[ScType] = Some(new ScType)
t: Option[ScType] = Some(ScType <at> 17ccb2f)
scala> class ScalaResolveResult
defined class ScalaResolveResult
scala> t match {case Some(r : ScalaResolveResult) => r case None => null}
scala.MatchError: Some(ScType <at> 17ccb2f)
at .<init>(<console>:8)
at .<clinit>(<console>)
at RequestResult$.<init>(<console>:3)
at RequestResult$.<clinit>(<console>)
at RequestResult$result(<console>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unkn...
scala>
Eugene.
the following session fails with MatchError for obvious reasons, but the compiler is happy with this code. Should it signal it? (I'm using 2.7.2-RC2)
scala> class ScType
defined class ScType
scala> var t : Option[ScType] = Some(new ScType)
t: Option[ScType] = Some(ScType <at> 17ccb2f)
scala> class ScalaResolveResult
defined class ScalaResolveResult
scala> t match {case Some(r : ScalaResolveResult) => r case None => null}
scala.MatchError: Some(ScType <at> 17ccb2f)
at .<init>(<console>:8)
at .<clinit>(<console>)
at RequestResult$.<init>(<console>:3)
at RequestResult$.<clinit>(<console>)
at RequestResult$result(<console>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unkn...
scala>
Eugene.
RSS Feed