File tree Expand file tree Collapse file tree 2 files changed +17
-15
lines changed Expand file tree Collapse file tree 2 files changed +17
-15
lines changed Original file line number Diff line number Diff line change @@ -601,6 +601,19 @@ object Types {
601
601
ctx.typeComparer.isSameType(this , that)
602
602
}
603
603
604
+ /** Is this type a primitive value type which can be widened to the primitive value type `to`? */
605
+ def isValueSubType (that : Type )(implicit ctx : Context ) = widenExpr match {
606
+ case self : TypeRef if defn.ScalaValueClasses contains self.symbol =>
607
+ that.widenExpr match {
608
+ case that : TypeRef if defn.ScalaValueClasses contains that.symbol =>
609
+ defn.isValueSubClass(self.symbol, that.symbol)
610
+ case _ =>
611
+ false
612
+ }
613
+ case _ =>
614
+ false
615
+ }
616
+
604
617
/** Is this type a legal type for a member that overrides another
605
618
* member of type `that`? This is the same as `<:<`, except that
606
619
* the types ()T and => T are identified, and T is seen as overriding
Original file line number Diff line number Diff line change @@ -382,21 +382,10 @@ trait Implicits { self: Typer =>
382
382
&& ! to.isError
383
383
&& ! ctx.isAfterTyper
384
384
&& (ctx.mode is Mode .ImplicitsEnabled )
385
- && { from.widenExpr match {
386
- case from : TypeRef if defn.ScalaValueClasses contains from.symbol =>
387
- to.widenExpr match {
388
- case to : TypeRef if defn.ScalaValueClasses contains to.symbol =>
389
- util.Stats .record(" isValueSubClass" )
390
- return defn.isValueSubClass(from.symbol, to.symbol)
391
- case _ =>
392
- }
393
- case from : ValueType =>
394
- ;
395
- case _ =>
396
- return false
397
- }
398
- inferView(dummyTreeOfType(from), to)(ctx.fresh.setExploreTyperState).isInstanceOf [SearchSuccess ]
399
- }
385
+ && from.isInstanceOf [ValueType ]
386
+ && ( from.isValueSubType(to)
387
+ || inferView(dummyTreeOfType(from), to)(ctx.fresh.setExploreTyperState).isInstanceOf [SearchSuccess ]
388
+ )
400
389
)
401
390
402
391
/** Find an implicit conversion to apply to given tree `from` so that the
You can’t perform that action at this time.
0 commit comments