Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
fix(sdk): Add support for Dart SDK 1.1
Browse files Browse the repository at this point in the history
Start using ClassMirror.instanceMembers (if available) or ClassMirror.declarations (SDK 1.1+).
  • Loading branch information
Kasper Lund authored and mhevery committed Jan 10, 2014
1 parent e97b9d0 commit 9d6914e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ node_js:
env:
matrix:
- JOB=unit-stable
# - JOB=unit-dev
- JOB=unit-dev
global:
- CHROME_BIN=/usr/bin/google-chrome

Expand Down
25 changes: 15 additions & 10 deletions lib/core/parser/eval_access.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,25 @@ abstract class AccessReflective {
}

static bool hasMember(InstanceMirror mirror, Symbol symbol) {
var type = mirror.type as dynamic;
var members = useInstanceMembers ? type.instanceMembers : type.members;
return members.containsKey(symbol);
return hasMethodHelper(mirror.type, symbol);
}

static final bool useInstanceMembers = computeUseInstanceMembers();
static bool computeUseInstanceMembers() {
static final Function hasMethodHelper = (() {
var objectType = reflect(Object).type;
try {
reflect(Object).type.instanceMembers;
return true;
} catch (e) {
return false;
// Use ClassMirror.instanceMembers if available. It contains local
// as well as inherited members.
objectType.instanceMembers;
return (type, symbol) => type.instanceMembers[symbol] is MethodMirror;
} on NoSuchMethodError catch (e) {
// For SDK 1.0 we fall back to just using the local members.
return (type, symbol) => type.members[symbol] is MethodMirror;
} on UnimplementedError catch (e) {
// For SDK 1.1 we fall back to just using the local declarations.
return (type, symbol) => type.declarations[symbol] is MethodMirror;
}
}
return null;
})();
}

/**
Expand Down
4 changes: 3 additions & 1 deletion lib/core/scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,9 @@ _toJson(obj) {
// work-around dartbug.com/14130
try {
ret = mirror.function.source;
} on NoSuchMethodError catch (e) {}
} on NoSuchMethodError catch (e) {
} on UnimplementedError catch (e) {
}
}
return true;
})());
Expand Down
4 changes: 3 additions & 1 deletion scripts/travis/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ esac
CHANNEL=`echo $JOB | cut -f 2 -d -`
echo Fetch Dart channel: $CHANNEL

echo http://storage.googleapis.com/dart-archive/channels/$CHANNEL/release/latest/sdk/$DART_SDK_ZIP
curl http://storage.googleapis.com/dart-archive/channels/$CHANNEL/release/latest/sdk/$DART_SDK_ZIP > $DART_SDK_ZIP
echo Fetched new dart version $(unzip -p $DART_SDK_ZIP dart-sdk/version)
rm -rf dart-sdk
unzip $DART_SDK_ZIP > /dev/null
rm $DART_SDK_ZIP

curl http://storage.googleapis.com/dart-archive/channels/$CHANNEL/release/latest/dartium/$DARTIUM_ZIP > $DARTIUM_ZIP
echo http://storage.googleapis.com/dart-archive/channels/$CHANNEL/raw/latest/dartium/$DARTIUM_ZIP
curl http://storage.googleapis.com/dart-archive/channels/$CHANNEL/raw/latest/dartium/$DARTIUM_ZIP > $DARTIUM_ZIP
unzip $DARTIUM_ZIP > /dev/null
rm -rf dartium
rm $DARTIUM_ZIP
Expand Down

0 comments on commit 9d6914e

Please sign in to comment.