| CODENOTIFIER | HelpYou are not signed inSign in |
Project: JRuby
Revision: 7635
Author: headius
Date: 03 Sep 2008 16:58:09
Changes:Duby import improvements: enlist imports table into more of typing process, expanding imported types earlier to reduce confusion and double-searching later.
Files:| ... | ...@@ -82,7 +82,7 @@ | |
| 82 | 82 | def learn_local_type(scope, name, type) |
| 83 | 83 | log "Learned local type under #{scope} : #{name} = #{type}" |
| 84 | 84 | |
| 85 | get_local_type_hash(scope)[name] = type | |
| 85 | get_local_type_hash(scope)[name] = known_types[type] || type | |
| 86 | 86 | end |
| 87 | 87 | |
| 88 | 88 | def local_type(scope, name) |
| ... | ...@@ -102,7 +102,11 @@ | |
| 102 | 102 | def learn_method_type(target_type, name, parameter_types, type) |
| 103 | 103 | log "Learned method #{name} (#{parameter_types}) on #{target_type} = #{type}" |
| 104 | 104 | |
| 105 | get_method_type_hash(target_type, name, parameter_types)[:type] = type | |
| 105 | get_method_type_hash(target_type, name, parameter_types)[:type] = known_types[type] || type | |
| 106 | ||
| 107 | # if it's any args are imported types, also add a mapping for the expanded name | |
| 108 | imported_types = parameter_types.map {|param| known_types[param] || param} | |
| 109 | get_method_type_hash(target_type, name, imported_types)[:type] = type | |
| 106 | 110 | end |
| 107 | 111 | |
| 108 | 112 | def method_type(target_type, name, parameter_types) |
| ... | ...@@ -114,7 +114,7 @@ | |
| 114 | 114 | |
| 115 | 115 | def infer(typer) |
| 116 | 116 | @inferred_type ||= begin |
| 117 | typer.known_types[name] || AST::type(name, false, true) | |
| 117 | typer.known_types[AST::type(name, false, true)] || AST::type(name, false, true) | |
| 118 | 118 | end |
| 119 | 119 | end |
| 120 | 120 | end |
| ... | ...@@ -13,8 +13,9 @@ | |
| 13 | 13 | end |
| 14 | 14 | |
| 15 | 15 | def infer(typer) |
| 16 | typer.known_types[short] = TypeReference.new(long, false, true) | |
| 17 | ||
| 16 | # add both the meta and non-meta imports | |
| 17 | typer.known_types[TypeReference.new(short, false, true)] = TypeReference.new(long, false, true) | |
| 18 | typer.known_types[TypeReference.new(short, false, false)] = TypeReference.new(long, false, false) | |
| 18 | 19 | TypeReference::NoType |
| 19 | 20 | end |
| 20 | 21 | end |