Skip to content

Commit

Permalink
Showing 4 changed files with 23 additions and 3 deletions.
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
## 0.18.4 (21-06.2016)
## 0.18.5 (27-06-2016)

* Added `OpenSSL::SSL::Socket#alpn_protocol`
* Added `IO#copy(src, desc, limit)` (thanks @jreinert)
* Added `TypeNode#instance` macro method
* [Several bugs fixes](https://github.com/crystal-lang/crystal/issues?q=milestone%3A0.18.5+is%3Aclosed)

## 0.18.4 (21-06-2016)

* Fixed [#2887](https://github.com/crystal-lang/crystal/issues/2887)
* Fix broken specs

## 0.18.3 (21-06.2016)
## 0.18.3 (21-06-2016)

* `TypeNode`: added `<`, `<=`, `>` and `>=` macro methods
* [Several bugs fixes](https://github.com/crystal-lang/crystal/issues?q=milestone%3A0.18.3+is%3Aclosed)

## 0.18.2 (16-06.2016)
## 0.18.2 (16-06-2016)

* Fixed building Crystal from the source tarball

6 changes: 6 additions & 0 deletions spec/compiler/macro/macro_methods_spec.cr
Original file line number Diff line number Diff line change
@@ -915,6 +915,12 @@ describe "macro methods" do
end
end

it "executes instance" do
assert_macro("x", "{{x.class.instance}}", "String") do |program|
[TypeNode.new(program.string)] of ASTNode
end
end

it "executes ==" do
assert_macro("x", "{{x == Reference}}", "false") do |program|
[TypeNode.new(program.string)] of ASTNode
5 changes: 5 additions & 0 deletions src/compiler/crystal/macros.cr
Original file line number Diff line number Diff line change
@@ -1203,6 +1203,11 @@ module Crystal::Macros
def class : TypeNode
end

# Returns the instance type of this type, if it's a class type,
# or `self` otherwise. This is the opposite of `#class`.
def instance : TypeNode
end

# Returns `true` if *other* is an ancestor of `self`.
def <(other : TypeNode) : BoolLiteral
end
2 changes: 2 additions & 0 deletions src/compiler/crystal/macros/methods.cr
Original file line number Diff line number Diff line change
@@ -1104,6 +1104,8 @@ module Crystal
end
when "class"
interpret_argless_method(method, args) { TypeNode.new(type.metaclass) }
when "instance"
interpret_argless_method(method, args) { TypeNode.new(type.instance_type) }
when "<", "<=", ">", ">="
interpret_one_arg_method(method, args) do |arg|
unless arg.is_a?(TypeNode)

0 comments on commit 9a9c49e

Please sign in to comment.