From a274f949c3aa9db16bd5addd0eed4f85388e74ed Mon Sep 17 00:00:00 2001 From: schinz Date: Sat, 26 Mar 2005 17:50:46 +0000 Subject: - introduced isInstanceOf$erased and asInstance... - introduced isInstanceOf$erased and asInstanceOf$erased methods, which work on the erased types; things to note: * before TypesAsValues phase, either variant can be used, although the erased ones need to be used with caution, when speed matters; * after TypesAsValues phase, only the erased variants should be used (done automatically by TreeGen); * when run time types are disabled, the TypesAsValues phase is not skipped anymore: it is turned into a trivial phase which rewrites all non-erased instanceof/casts into erased ones. --- sources/scalac/ast/TreeGen.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'sources/scalac/ast') diff --git a/sources/scalac/ast/TreeGen.java b/sources/scalac/ast/TreeGen.java index 31389a3227..43d1fc1ed5 100644 --- a/sources/scalac/ast/TreeGen.java +++ b/sources/scalac/ast/TreeGen.java @@ -641,8 +641,10 @@ public class TreeGen implements Kinds, Modifiers, TypeTags { /** Builds an instance test with given value and type. */ public Tree mkIsInstanceOf(int pos, Tree value, Type type) { - Type[] targs = new Type[]{type}; - return mkApplyT_(pos, Select(value, definitions.ANY_IS), targs); + Symbol sym = global.currentPhase.id >= global.PHASE.TYPESASVALUES.id() + ? definitions.ANY_IS_ERASED + : definitions.ANY_IS; + return mkApplyT_(pos, Select(value, sym), new Type[]{type}); } public Tree mkIsInstanceOf(Tree value, Type type) { return mkIsInstanceOf(value.pos, value, type); @@ -650,8 +652,10 @@ public class TreeGen implements Kinds, Modifiers, TypeTags { /** Builds a cast with given value and type. */ public Tree mkAsInstanceOf(int pos, Tree value, Type type) { - Type[] targs = new Type[]{type}; - return mkApplyT_(pos, Select(value, definitions.ANY_AS), targs); + Symbol sym = global.currentPhase.id >= global.PHASE.TYPESASVALUES.id() + ? definitions.ANY_AS_ERASED + : definitions.ANY_AS; + return mkApplyT_(pos, Select(value, sym), new Type[]{type}); } public Tree mkAsInstanceOf(Tree value, Type type) { return mkAsInstanceOf(value.pos, value, type); -- cgit v1.2.3