File tree Expand file tree Collapse file tree 3 files changed +10
-1
lines changed
compiler/src/dotty/tools/dotc/ast Expand file tree Collapse file tree 3 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -963,8 +963,10 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
963963
964964 /** `tree.isInstanceOf[tp]`, with special treatment of singleton types */
965965 def isInstance (tp : Type )(using Context ): Tree = tp.dealias match {
966+ case ConstantType (c) if c.tag == StringTag =>
967+ singleton(tp).equal(tree)
966968 case tp : SingletonType =>
967- if ( tp.widen.derivesFrom(defn.ObjectClass ))
969+ if tp.widen.derivesFrom(defn.ObjectClass ) then
968970 tree.ensureConforms(defn.ObjectType ).select(defn.Object_eq ).appliedTo(singleton(tp))
969971 else
970972 singleton(tp).equal(tree)
Original file line number Diff line number Diff line change 1+ object A :
2+ type Timeframe = " 1m" | " 2m" | " 1H"
3+
4+ def test (input : String ) = input.isInstanceOf [Timeframe ]
Original file line number Diff line number Diff line change 1+ @ main def Test =
2+ val x = " 1"
3+ assert(A .test(x + " m" ))
You can’t perform that action at this time.
0 commit comments